<?php

class Units extends Eloquent {
    protected $table = 'units';
     public static function Select($shop_id)
    {
        try{

            $query_select="SELECT *  FROM units where shop_id = $shop_id ";
            return DB::select(DB::raw($query_select));
        }
        catch(Exception $e)
        {
            throw $e;
        }
    }
    public static function Insert($name,$comments,$shop_id)
    {
      try{
            $units= new Units();
            $units->name = $name;
            $units->comments =$comments;
            $units->shop_id =$shop_id;
           // $units->id = $units_id; 
            $units->save();
            $units_id = $units->id;
            return $units_id;
        }
        catch(Exception $e)
        {
            throw $e;
        }
    }
     public static function Edit($name,$comments,$units_id)
    {

        try{

            $query_edit =" UPDATE units 
                           SET updated_at=CURRENT_TIMESTAMP,name = '$name',comments = '$comments',id='$units_id'
                           WHERE id = $units_id";
            $query= DB::update($query_edit);
            return true;
        }
        catch(Exception $e)
        {
            throw $e;
        }
    }
    
    
       public static function Del($units_id){
        try{
            $query_delete ="DELETE FROM units WHERE id = '$units_id'";
            $delete=DB::delete($query_delete);
            return true;
        }
        catch(Exception $e){
            throw $e;
        }
    }

}
